//
//  ClubEditHeaderViewCell.m
//  Shengzhuli
//
//  Created by FXGuo on 2017/7/3.
//  Copyright © 2017年 kamangkeji. All rights reserved.
//

#import "ClubEditHeaderViewCell.h"
#import "AddressField.h"
#import <UIButton+WebCache.h>

@interface ClubEditHeaderViewCell ()

@property (weak, nonatomic) IBOutlet UITextField *nameField;
@property (weak, nonatomic) IBOutlet AddressField *desTextView;
@property (weak, nonatomic) IBOutlet UIButton *bgImageBtn;
@property (weak, nonatomic) IBOutlet UIButton *logoBtn;

@end

@implementation ClubEditHeaderViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        self.desTextView.placeHolder = @"请输入俱乐部介绍";
    });
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(textDidChanged:) name:UITextViewTextDidChangeNotification object:nil];
}
- (IBAction)textFieldChanged:(UITextField *)field
{
    self.editModel.clubName = field.text;
}
- (void)textDidChanged:(NSNotification *)noti
{
    UITextView *textview = noti.object;
    self.editModel.content = textview.text;
}

- (IBAction)btnClick:(UIButton *)btn
{
    if (self.uploadPhoto) {
        self.uploadPhoto(btn);
    }
}
- (void)setEditModel:(ClubModel *)editModel
{
    _editModel = editModel;
    [self.bgImageBtn sd_setBackgroundImageWithURL:[NSURL URLWithString:editModel.backgroundImg] forState:UIControlStateNormal placeholderImage:GetImage(@"default_goods_image")];
    [self.logoBtn sd_setBackgroundImageWithURL:[NSURL URLWithString:editModel.clubLogo] forState:UIControlStateNormal placeholderImage:GetImage(@"person_avatar")];
    self.nameField.text = editModel.clubName;
    self.desTextView.text = editModel.content;
}


@end
